home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 3020 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  2.0 KB

  1. Path: news.uh.edu!usenet
  2. From: Sensarn <txs53132@bayou.uh.edu>
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: displaying pictures
  5. Date: 21 Jan 1996 17:48:01 GMT
  6. Organization: AEtna Insurance Agency
  7. Message-ID: <4dtu8h$ffa@masala.cc.uh.edu>
  8. References: <4bd2r6$fk@cloner2.ix.netcom.com> <4dr2js$o6v@osprey.unf.edu>
  9. NNTP-Posting-Host: sip-14265.public-dialups.uh.edu
  10. Mime-Version: 1.0
  11. Content-Type: text/plain; charset=us-ascii
  12. Content-Transfer-Encoding: 7bit
  13. X-Mailer: Mozilla 1.1 (Windows; U; 16bit)
  14.  
  15. It also depends on which screen mode you are using.  You can't display 
  16. pictures (other than ASCII art) on the default text mode (3).  You must 
  17. invoke a video mode.  I use mode 13h because it has a linear 
  18. configuration:
  19.  
  20. asm {
  21.     mov ax,0x13
  22.     int 10
  23. }
  24.  
  25. To load the pictures you must decode the format.  Here is a brief 
  26. overview of the PCX file format (256 colors):
  27.  
  28. 1) Header info (128 bytes)
  29. 2) RLE encoded data
  30.     A) Encoded values are preceded with a byte that is > 192
  31.        (the top two bits are signed if RLE encoding is taking effect)
  32.        1) You must first remove the signed bits.
  33.           The value after the subtraction (-192) is the run length.
  34.           Store this value in a variable (n).
  35.        2) Read the next byte.  This byte is the actual color value.
  36.           This byte must be displayed n times.
  37.     B) The values are not encoded if the top two bits aren't signed.
  38.        You can verify this -- they will be less than 192.
  39.        These pixels are displayed once.
  40. 3) 256 color palette
  41.     A) You must read 3 bytes -- red, green, and blue
  42.        1) Each color only uses the bottom 6 bits.
  43.           You need to shift the byte right twice (divide by four).
  44.     B) You can change to the new color by doing the following:
  45.        outp(0x3C6,0xFF) //Initialization
  46.        outp(0x3C8,color_index) //Choose the new color
  47.        outp(0x3C9,red) //Send red value
  48.        outp(0x3C9,green) //Send green value
  49.        outp(0x3C9,blue) //Send blue value
  50.  
  51. Steven Sensarn - txs53132@bayou.uh.edu 
  52.   
  53.  
  54.     
  55.  
  56.